/**
 * CommentItem
 * - author faryangsh@163.com
 */
import React, {Component} from 'react'
import PropTypes from 'prop-types'

// 定义评论组件类
class CommentItem extends Component {

    delete = () => {
        /*if (window.confirm(`are you sure delete this ${this.props.comment.name}`)){
        }*/
        // debugger
        this.props.deleteComment(this.props.index)
    }

    render() {
        const comment = this.props.comment;
        return (
            <li className="list-group-item">
                <div className="handle">
                    <a href="javascript:;" onClick={this.delete}>删除</a>
                </div>
                <p className="user"><span>{comment.name}</span><span>说:</span></p>
                <p className="centence">{comment.content}</p>
            </li>
        )

    }
}

CommentItem.protoTypes = {
    comment: PropTypes.object.isRequired,
    deleteComment: PropTypes.func.isRequired,
    index: PropTypes.number.isRequired

}

export default CommentItem;